package com.edison.fallback;

import com.edison.common.BusinessException;
import com.edison.feign.DemoService2;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author Liangxing
 */
@Component
@Slf4j
public class DemoService2FallBackFactory implements FallbackFactory<DemoService2> {



    @Override
    public DemoService2 create(Throwable throwable) {
        return type -> {
            log.error("来自service-2 内部错误", throwable);

            log.error("来自service-2 内部错误:{}", throwable.getMessage());
            throw new BusinessException("来自service-2 内部错误" );
        };
    }
}
